#pragma once
#ifdef __ANDROID__
#include <android/api-level.h>
#include <android/log.h>
#include <string>

#define PRNT(...) __android_log_print(ANDROID_LOG_INFO, "Version-Info", __VA_ARGS__)

class AVersion {
public:
    static void printInfo() {
        int sdkVersion = android_get_device_api_level();
        std::string androidVersionName = getAndroidVersionName(sdkVersion);
        PRNT("SDK Version: %d, %s", sdkVersion, androidVersionName.c_str());

        std::string ndkVersion = getNdkVersion();
        std::string clangVersion = getClangVersion();
        PRNT("NDK Version: %s, Clang Version: %s", ndkVersion.c_str(), clangVersion.c_str());
    }
    
private:
    static std::string getAndroidVersionName(int sdkVersion) {
        switch (sdkVersion) {
            case 34: return "Android 14";
            case 33: return "Android 13";
            case 32: return "Android 12L";
            case 31: return "Android 12";
            case 30: return "Android 11";
            case 29: return "Android 10";
            case 28: return "Android 9 (Pie)";
            case 27: return "Android 8.1 (Oreo)";
            case 26: return "Android 8.0 (Oreo)";
            case 25: return "Android 7.1 (Nougat)";
            case 24: return "Android 7.0 (Nougat)";
            case 23: return "Android 6.0 (Marshmallow)";
            case 22: return "Android 5.1 (Lollipop)";
            case 21: return "Android 5.0 (Lollipop)";
            case 19: return "Android 4.4 (KitKat)";
            case 18: return "Android 4.3 (Jelly Bean)";
            case 17: return "Android 4.2 (Jelly Bean)";
            case 16: return "Android 4.1 (Jelly Bean)";
            case 15: return "Android 4.0.3 (Ice Cream Sandwich)";
            case 14: return "Android 4.0 (Ice Cream Sandwich)";
            default: return "Unknown Android Version";
        }
    }

    static std::string getNdkVersion() {
        return std::to_string(__NDK_MAJOR__) + "." +
               std::to_string(__NDK_MINOR__) + "." +
               std::to_string(__NDK_BETA__);
    }

    static std::string getClangVersion() {
        return std::to_string(__clang_major__) + "." +
               std::to_string(__clang_minor__) + "." +
               std::to_string(__clang_patchlevel__);
    }
};

#endif